package com.shqcjd.yunweiyanoperator.ui.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.yunweiyanoperator.R;
import com.shqcjd.yunweiyanoperator.model.pojo.MsgBean;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 系统消息
 * Created by sy on 2019/3/21.
 */

public class MessageListAdapter extends BaseQuickAdapter<MsgBean.ListBean,MessageListAdapter.ViewHolder> {

    public MessageListAdapter() {
        super(R.layout.item_message);
    }

    @Override
    protected void convert(MessageListAdapter.ViewHolder helper, MsgBean.ListBean item) {
        helper.tv_title.setText(item.title);
        helper.tv_content.setText(item.body);
        helper.tv_time.setText(item.sendTime);

        if (item.isRead == 1) {//	0:未读、1：已读
            helper.iv_red_dot.setVisibility(View.GONE);
        } else {
            helper.iv_red_dot.setVisibility(View.VISIBLE);
        }

        if (item.type == 3) {//1:通知,2:好友请求,3:视频发送请求
            helper.tv_name.setVisibility(View.VISIBLE);
            helper.tv_name.setText("发送人:"+item.senderUserName);
        } else {
            helper.tv_name.setVisibility(View.GONE);
        }
    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.tv_title)
        TextView tv_title;
        @BindView(R.id.tv_content)
        TextView tv_content;
        @BindView(R.id.tv_time)
        TextView tv_time;
        @BindView(R.id.iv_red_dot)
        ImageView iv_red_dot;
        @BindView(R.id.tv_name)
        TextView tv_name;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}